//
//  CYMine_FriendTableViewCell.m
//  cyydt
//
//  Created by chu on 2019/1/29.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYMine_FriendTableViewCell.h"

@implementation CYMine_FriendTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.headImageView.layer.cornerRadius = self.headImageView.frame.size.height / 2;
    self.headImageView.layer.masksToBounds = YES;
    
    self.guanzhuBtn.layer.cornerRadius = 2;
    self.guanzhuBtn.layer.masksToBounds = YES;
    self.guanzhuBtn.layer.borderWidth = 1;
    
    self.shenfenLabel.layer.cornerRadius = 2;
    self.shenfenLabel.layer.masksToBounds = YES;
}

- (void)setModel:(CYFriendModel *)model{
    _model = model;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size]];
    self.nicknamelabel.text = model.nickName;
    self.typeImageView.hidden = NO;
    self.shenfenLabel.hidden = NO;
    if ([model.tag isEqualToString:@"1"]) {
        //普通
        self.typeImageView.hidden = YES;
        self.shenfenLabel.hidden = YES;
        
    }else if ([model.tag isEqualToString:@"2"]){
        //导师号
        self.typeImageView.image = [UIImage imageNamed:@"wd_gezl_dsbq"];
        self.shenfenLabel.text = @"导师号";
    }else if ([model.tag isEqualToString:@"3"]){
        //官方号
        self.typeImageView.image = [UIImage imageNamed:@"wd_gezl_gfbq"];
        self.shenfenLabel.text = @"官方号";
    }else{
        //项目号
        self.typeImageView.image = [UIImage imageNamed:@"标签"];
        self.shenfenLabel.text = @"项目号";
    }
    
    if ([model.isAttent isEqualToString:@"0"]) {
        //未关注
        [self.guanzhuBtn setTitle:@"+ 关注" forState:UIControlStateNormal];
        self.guanzhuBtn.layer.borderWidth = 0;
        [self.guanzhuBtn setBackgroundColor:RGBOF(0xFF5353)];
        [self.guanzhuBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }else{
        [self.guanzhuBtn setTitle:@"已关注" forState:UIControlStateNormal];
        self.guanzhuBtn.layer.borderWidth = 1;
        self.guanzhuBtn.layer.borderColor = RGBOF(0xE3E3E3).CGColor;
        [self.guanzhuBtn setBackgroundColor:[UIColor whiteColor]];
        [self.guanzhuBtn setTitleColor:RGBOF(0x999999) forState:UIControlStateNormal];

    }
    
    self.introLabel.text = model.cy_description;
}

- (void)setYaoqingModel:(CYFriendModel *)yaoqingModel{
    _yaoqingModel = yaoqingModel;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:yaoqingModel.avatar] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size]];
    self.nicknamelabel.text = yaoqingModel.nickname;
    self.typeImageView.hidden = NO;
    self.shenfenLabel.hidden = NO;
    if ([yaoqingModel.tag isEqualToString:@"1"]) {
        //普通
        self.typeImageView.hidden = YES;
        self.shenfenLabel.hidden = YES;
        
    }else if ([yaoqingModel.tag isEqualToString:@"2"]){
        //导师号
        self.typeImageView.image = [UIImage imageNamed:@"wd_gezl_dsbq"];
        self.shenfenLabel.text = @"导师号";
    }else if ([yaoqingModel.tag isEqualToString:@"3"]){
        //官方号
        self.typeImageView.image = [UIImage imageNamed:@"wd_gezl_gfbq"];
        self.shenfenLabel.text = @"官方号";
    }else{
        //项目号
        self.typeImageView.image = [UIImage imageNamed:@"标签"];
        self.shenfenLabel.text = @"项目号";
    }
    
    if ([yaoqingModel.isInvite integerValue] == 1) {
        //已邀请
        [self.guanzhuBtn setTitle:@"已邀请" forState:UIControlStateNormal];
        self.guanzhuBtn.layer.borderColor = RGBOF(0xE3E3E3).CGColor;
        [self.guanzhuBtn setTitleColor:RGBOF(0x999999) forState:UIControlStateNormal];
    }else{
        [self.guanzhuBtn setTitle:@"邀请" forState:UIControlStateNormal];
        self.guanzhuBtn.layer.borderColor = RGBOF(0xFF5353).CGColor;
        [self.guanzhuBtn setTitleColor:RGBOF(0xFF5353) forState:UIControlStateNormal];
        
    }
    
    self.introLabel.text = yaoqingModel.cy_description;
}

- (IBAction)guanzhuAction:(UIButton *)sender {
    if (self.block) {
        self.block();
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
